///////////////////////////////////////////////Linpop newly/////////////////////////////////////////


#ifndef PTP_H_INCLUDED
#define FUNCTION_H_INCLUDED
#include"LinpopHeaders.h"

#include<gtk/gtk.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>

#define IPSENDTO "0.0.0.0"
GtkBuilder * builder;
GtkBuilder * builder2;
GtkWidget * window;
GtkWidget *recordwindow;
GtkWidget *expression_window;//聊天表情窗口
GtkWidget *infowindow;//聊天信息窗口
GtkWidget * btnsend;
GtkWidget * textView_send;
GtkWidget * textView_show;

GtkWidget * textView_gpsend;
GtkWidget * textView_gpshow;

GtkWidget * textview_record;


GtkTextBuffer * buf_send;
GtkTextBuffer * buf_recv;
GtkTextBuffer * buf_gpsend;
GtkTextBuffer * buf_gprecv;
GtkTextBuffer * buf_record;
GtkTextIter start_ltt,end_ltt;
//gchar *myip = "10.1.232.223";
//gchar *sendip = "10.1.232.10";
FILE * recordfile;//聊天记录文件的句柄
clientRequest clientinfo;//保存你要聊天的对象的信息的结构体
GtkWidget *filew;//文件选择控件
gchar * filepath;
gchar * senderip;
gchar * fileoptype;
gint exp_offset = -1;
gchar exp_path[NAMELEN];
gchar exp_num[2] = {0};


void * send_func(void * arg);

void close_window(GtkObject *object,gpointer user_data)
{
    int m,n;
    for(m=0;m<user_num;m++)
    {
        if(strcmp(user_window[m].Name,clientinfo.senderName) ==0)
        n = m;
    }
    user_window[n].flag = 0;
    fclose(recordfile);
    gtk_main_quit();
}



void show_message()
{
    GtkTextIter iter1;

    char *recordBuf =NULL;
    int nlen =0;
    fseek(recordfile,0,SEEK_END); //文件指针移到文件尾
   //GtkTextMark   	*mark;

    nlen =ftell(recordfile);//得到当前指针位置, 即是文件的长度
    rewind(recordfile);//文件指针恢复到文件头位置
    //动态申请空间, 为保存字符串结尾标志\0, 多申请一个字符的空间
	recordBuf = (char*) malloc(sizeof(char)*nlen+1);
	if(!recordBuf)
	{
		perror("内存不够!\n");
		exit(0);
	}
	//读取文件内容//读取的长度和源文件长度有可能有出入，这里自动调整 nLen
	nlen = fread(recordBuf, sizeof(char), nlen, recordfile);

	recordBuf[nlen] = '\0'; //添加字符串结尾标志

	//g_print("%s\n", recordBuf); //把读取的内容输出到屏幕看看

	buf_record = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview_record));
    gtk_text_buffer_get_iter_at_offset(buf_record, &iter1, -1);
     gtk_text_buffer_insert_with_tags_by_name (buf_record, &iter1, recordBuf, -1,NULL,NULL ,NULL);
 //  gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW(textview_record), mark);

     free(recordBuf); //释放空间


}
/****************************************************************/
//刷新 清除 关闭 按钮的回掉函数
void on_btn_close_clicked(GtkObject *object,gpointer user_data)
{
    gtk_widget_hide(GTK_WIDGET(recordwindow));
}

void on_btn_refurbish_clicked(GtkObject *object,gpointer user_data)
{
    gtk_text_buffer_set_text(buf_record,"",-1);
    show_message();
}


void on_btn_clear_clicked(GtkObject *object,gpointer user_data)
{
    gtk_text_buffer_set_text(buf_record,"",-1);
}
/**************************************************************/
void show_recording_window(GtkObject *object,gpointer user_data)
{

    //pthread_t showmsg;
    GtkWidget *closebutton;
    GtkWidget *refurbishbutton;
    GtkWidget *clearbutton;
 //   pthread_create(&showmsg, NULL, show_message, NULL);
   builder2 = gtk_builder_new();
	gtk_builder_add_from_file(builder2,"recording.glade",NULL);

	recordwindow = GTK_WIDGET(gtk_builder_get_object(builder2,"window_record"));
	textview_record = GTK_WIDGET(gtk_builder_get_object(builder2,"textview_record"));
	closebutton = GTK_WIDGET(gtk_builder_get_object(builder2,"btn_close"));
	refurbishbutton =GTK_WIDGET(gtk_builder_get_object(builder2,"btn_refurbish"));
	clearbutton = GTK_WIDGET(gtk_builder_get_object(builder2,"btn_clear"));
        show_message();
	gtk_builder_connect_signals(builder2,NULL);
	g_signal_connect(G_OBJECT(closebutton),"clicked",G_CALLBACK(on_btn_close_clicked),NULL);
	g_signal_connect(G_OBJECT(refurbishbutton),"clicked",G_CALLBACK(on_btn_refurbish_clicked),NULL);
	g_signal_connect(G_OBJECT(clearbutton),"clicked",G_CALLBACK(on_btn_clear_clicked),NULL);

	g_object_unref(G_OBJECT(builder2));
    gtk_widget_show(GTK_WIDGET(recordwindow));
    gtk_main();
}

void on_BTN_send_clicked(GtkObject *object,clientRequest * user_data)
{

        GtkWidget *image;
        GtkTextChildAnchor *anchor;
        GtkTextIter iter;

        gchar buf[5][NAMELEN];
//        gchar ch ;
    clientRequest usermsg = *user_data;
  //  g_print("user_name :%s \n",usermsg.senderName);
  //  g_print("user_age :%d \n",usermsg.age);
    gchar sendmessage[1024];
	//g_print("OK!");
	//pthread_t send_thread;
	//pthread_create(&send_thread, NULL, send_func, NULL);
	GtkTextIter start,end;           /*定义迭代器起点终点*/
    gchar * S_text;
    int sendSockfd;
    struct sockaddr_in sin_addr;
      sendSockfd = socket(AF_INET, SOCK_DGRAM, 0);
    bzero(&sin_addr, sizeof(sin_addr));
 //   setsockopt(sendSockfd,SOL_SOCKET,SO_BROADCAST,&sendSockfd,sizeof(sendSockfd));
    sin_addr.sin_family = AF_INET;
    sin_addr.sin_addr.s_addr = inet_addr(SERVERIP);
    sin_addr.sin_port = htons(9741);


    buf_send = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textView_send));     /*获取文本区*/
    gtk_text_buffer_get_start_iter(buf_send,&start);                                          /*得到当前文本区域的起始位置*/
    gtk_text_buffer_get_end_iter(buf_send,&end);                                              /*得到当前文本区域的结束位置*/
    S_text = gtk_text_buffer_get_text(buf_send,&start,&end,TRUE);         /*返回start end之间的所有文本，最后一个参数是TRUE的话那么可见的文本都将被返回*/
 //  g_print("send: %s\n",S_text);
        g_print("before for1!\n");
        int i;
        for(i = 0; i < 5; i++)
        {
                bzero(buf[i], NAMELEN);
        }
        strcpy(buf[0], S_text);
        if(exp_offset >= 0)
        {
                g_print("before for2!\n");
                g_print("exp_offset: %d\n", exp_offset);
                for(i = 0; i < exp_offset; i++)
                {
                        buf[1][i] = buf[0][i];
                }
                g_print("before for3!\n");
                int j = 0;
                while(buf[0][i] != '\0')
                {
                        buf[2][j] = buf[0][i];
                        j++;
                        i++;
                }
                g_print("buf[0]:%s\n",buf[0]);
                g_print("buf[1]:%s\n",buf[1]);
                g_print("buf[2]:%s\n",buf[2]);

                g_print("exp_path:%s\n", exp_path);
                i = 0;
                j = 0;
                bzero(exp_num,sizeof(exp_num));
                while(exp_path[j] != '\0')
                {
                        if(exp_path[j] == '/')
                        {
                                j++;
                                while(exp_path[j] != '.')
                                {
                                        exp_num[i] = exp_path[j];
                                        printf("exp_num[i]: %c\n", exp_num[i]);
                                        i++;
                                        j++;
                                }
                        }
                        j++;
                }
                bzero(buf[0],sizeof(buf[0]));
                strcat(buf[0], buf[1]);
                strcat(buf[0], "/");
                strcat(buf[0], exp_num);
                strcat(buf[0], "/");
                strcat(buf[0], buf[2]);
        }


        g_print("buf[0]: %s\n", buf[0]);
        //strcpy(S_text, buf[0]);

            bzero(sendmessage,sizeof(sendmessage));
                sendmessage[0] = '2';
                strcat(sendmessage,"~");                                                                                                                                //组包
                strcat(sendmessage,myinformation.senderName);
                strcat(sendmessage,"~");
                strcat(sendmessage,usermsg.senderName);
                strcat(sendmessage,"~");
                //strcat(message,Register_PasswdEntry_char);
                strcat(sendmessage,"~");
                //sourceIP
                strcat(sendmessage,"~");

                strcat(sendmessage,usermsg.sourceIP);

                strcat(sendmessage,"~");
                //nickname
                strcat(sendmessage,"~");
                //state
                strcat(sendmessage,"~");
                //strcat(message,Register_GenderEntry_char);
                strcat(sendmessage,"~");
                //strcat(message,Register_AgeEntry_char);
                strcat(sendmessage,"~");
                //strcat(message,Register_DepartEntry_char);
                strcat(sendmessage,"~");
                //tel
                strcat(sendmessage,"~");
                //birth
                strcat(sendmessage,"~");
                //profilepic
                strcat(sendmessage,"~");
                //msg
                strcat(sendmessage,buf[0]);
                strcat(sendmessage,"~");


    /*可以输出文本区域的内容*/
    //在聊天对话框的上面文本框里显示自己输入的内容
    char time_msg[50];
    time_t now;
    struct tm * ptr;
    char resultBuf[1500] = {0};

    time(&now);
    ptr = localtime(&now);
    strftime(time_msg,sizeof(time_msg),"%T", ptr);
    sendto(sendSockfd, sendmessage, strlen(sendmessage)+1,0, (struct sockaddr *)&sin_addr, sizeof(sin_addr));

    close(sendSockfd);

        if(exp_offset >= 0)
        {
                int  j  = 0;
                while(buf[0][j] != '/')
                {
                        buf[3][j] = buf[0][j];
                        j++;
                }
                j++;
                int k = 0;
                while(buf[0][j]  != '/')
                {
                        exp_num[k] = buf[0][j];
                        j++;
                        k++;
                }
                j++;
                int l = 0;
                while(buf[0][j]  != '\0')
                {
                        buf[4][l] = buf[0][j] ;
                        l++;
                        j++;
                }
                g_print("Mine buf[0]: %s\n",buf[0]);
                g_print("Mine buf[3]: %s\n",buf[3]);
                g_print("Mine buf[4]: %s\n",buf[4]);
                strcat(buf[4], "\n");

                sprintf(resultBuf,"%s     %s\n    %s",myinformation.senderName,time_msg, buf[3]);
                g_print("resultBuf:%s\n",resultBuf);

                bzero(exp_path,sizeof(exp_path));
                buf_recv = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textView_show));
                gtk_text_buffer_get_end_iter(buf_recv,&iter);
                gtk_text_buffer_insert_with_tags_by_name (buf_recv, &iter, resultBuf, -1, NULL,NULL, NULL);
                bzero(resultBuf,sizeof(resultBuf));
                gtk_text_buffer_get_end_iter(buf_recv,&iter);

                if((buf[3][0] != '\0') || (buf[4][0] != '\0'))
                {
                        strcat(exp_path, "CustomFace/");
                        strcat(exp_path, exp_num);
                        strcat(exp_path, ".gif");
                        image = gtk_image_new_from_file(exp_path);

                        g_print("exp_path:%s\n",exp_path);

                        image=gtk_image_new_from_file(exp_path);
                        anchor = gtk_text_buffer_create_child_anchor(buf_recv,&iter);
                        gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(textView_show),image,anchor);
                        gtk_widget_show(image);
                }

                gtk_text_buffer_get_end_iter(buf_recv,&iter);
                gtk_text_buffer_insert_with_tags_by_name (buf_recv, &iter, buf[4], -1, NULL,NULL, NULL);
        }
        else
        {
                sprintf(resultBuf,"%s     %s\n    %s\n",myinformation.senderName,time_msg, buf[0]);
                bzero(exp_path,sizeof(exp_path));
                buf_recv = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textView_show));
                gtk_text_buffer_get_end_iter(buf_recv,&iter);
                gtk_text_buffer_insert_with_tags_by_name (buf_recv, &iter, resultBuf, -1, NULL,NULL, NULL);
                bzero(resultBuf,sizeof(resultBuf));
                gtk_text_buffer_get_end_iter(buf_recv,&iter);


        }
                        fseek(recordfile , 0, SEEK_CUR);
                       // fputs(resultBuf,recordfile);
                fwrite(resultBuf ,strlen(resultBuf),1,recordfile);
             //  buf_recv = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textView_show));
              //  gtk_text_buffer_get_iter_at_offset(buf_recv , &iter , -1);
              // gtk_


                                //(recordfile,resultBuf,strlen(resultBuf)+1);//写入聊天记录文件


                                //gtk_text_buffer_get_iter_at_offset(buf_recv, &iter, 0);
                                //gtk_text_buffer_get_end_iter(buf_recv,&end);



                                //gtk_text_buffer_get_iter_at_offset  (buf_recv,&iter,j-1);





                                //gtk_text_buffer_get_iter_at_offset  (buf_recv,&iter,j);



 //   bzero(chat_msg[i].Name,NAMELEN);
 //   bzero(chat_msg[i].msg, 1024);


    //g_print ("message :%s \n",sendmessage);
        bzero(sendmessage,sizeof(sendmessage));
        gtk_text_buffer_set_text(buf_send,"",-1);
        exp_offset = -1;
        close(sendSockfd);
}


void * recv_func(void * arg)
{
        //GtkTextBuffer * buffer;
        GtkTextIter iter;
        GtkWidget *image;
        GtkTextChildAnchor *anchor;

        gchar mybuf[5][NAMELEN];
        char resultBuf[1500] = {0};
        char time_msg[50];
        time_t now;
        struct tm * ptr;
         buf_recv = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textView_show));

        while(1)
        {
                int i = 0;
                for(i = 0; i < 10; i++)
                {
                        if(strcmp(chat_msg[i].Name, clientinfo.senderName) == 0)
                        {
                                int t = 0;
                                for(t = 0; t < 5; t++)
                                {
                                        bzero(mybuf[t],NAMELEN);
                                }
                                //GtkTextMark * recvmark;
                                //GtkTextIter end;
                                time(&now);
                                ptr = localtime(&now);
                                strftime(time_msg,sizeof(time_msg),"%T", ptr);

                               int flag = 0;
                                t = 0;
                                while(chat_msg[i].msg[t] != '\0')
                                {
                                        if(chat_msg[i].msg[t] == '/')
                                        {
                                                flag = 1;
                                        }
                                        t++;
                                        break;
                                }

                                printf("flae= %d\n",flag);
 //                               g_print("mybuf:%s\n",mybuf);

                                if(flag == 1)
                                {
                                        int j ;
                                        for( j = 0;(chat_msg[i].msg[j] != '/'&&chat_msg[i].msg[j] !='\0') ;  j++)
                                        {
                                                mybuf[0][j] = chat_msg[i].msg[j];
                                        }
                                        j++;
                                        printf("j1:%d",j);
                                        int k = 0;
                                        for( ;chat_msg[i].msg[j] != '/' && chat_msg[i].msg[j] != '\0'; j++,k++)
                                        {
                                                exp_num[k] = chat_msg[i].msg[j];
                                        }
                                        j++;
                                        printf("j2:%d",j);
                                        int l = 0;
                                        for( ; chat_msg[i].msg[j] != '\0';j++,l++)
                                        {
                                                mybuf[1][l] = chat_msg[i].msg[j];

                                        }
                                        printf("j3:%d",j);
                                        strcat(mybuf[1], "\n");

                                        g_print("mybuf[0]:%s\n",mybuf[0]);
                                        g_print("mybuf[1]:%s\n",mybuf[1]);
                                        g_print("mybuf[2]:%s\n",mybuf[2]);




                                                sprintf(resultBuf,"%s     %s\n    %s",chat_msg[i].Name,time_msg, mybuf[0]);
                                                g_print("resultBuf:%s\n",resultBuf);

                                                bzero(exp_path,sizeof(exp_path));

                                                buf_recv = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textView_show));
                                                gtk_text_buffer_get_end_iter(buf_recv,&iter);

                                                gtk_text_buffer_insert_with_tags_by_name (buf_recv, &iter, resultBuf, -1, NULL,NULL, NULL);
                                                bzero(resultBuf,sizeof(resultBuf));
                                                //gtk_text_buffer_get_end_iter(buf_recv,&iter);
                                    //    if((mybuf[0][0] != '\0') || (mybuf[1][0] != '\0'))
                                //       {

                                               // strcat(exp_path, "./CustomFace/");
                                               // strcat(exp_path, exp_num);
                                               // strcat(exp_path, ".gif");
                                                sprintf(exp_path,"./CustomFace/%s.gif",exp_num);
                                                image = gtk_image_new_from_file(exp_path);

                                                g_print("exp_path:%s\n",exp_path);

                                                image=gtk_image_new_from_file(exp_path);
                                                anchor = gtk_text_buffer_create_child_anchor(buf_recv,&iter);
                                                gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(textView_show),image,anchor);
                                                gtk_widget_show(image);
                                    //    }

                                         gtk_text_buffer_get_end_iter(buf_recv,&iter);
                                        //gtk_text_buffer_get_iter_at_offset  (buf_recv,&iter,j);
                                        gtk_text_buffer_insert_with_tags_by_name (buf_recv, &iter, mybuf[1], -1, NULL,NULL, NULL);

                                        gtk_text_buffer_set_text(buf_send," ",-1);
                                        exp_offset = 0;


                                }
                                else
                                {
                                        sprintf(resultBuf,"%s     %s\n    %s\n",chat_msg[i].Name,time_msg, chat_msg[i].msg);
                                        g_print("resultBuf:%s\n",resultBuf);

                                        //bzero(exp_path,sizeof(exp_path));

                                        buf_recv = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textView_show));
                                        gtk_text_buffer_get_end_iter(buf_recv,&iter);

                                        gtk_text_buffer_insert_with_tags_by_name (buf_recv, &iter, resultBuf, -1, NULL,NULL, NULL);
                                        bzero(resultBuf,sizeof(resultBuf));
                                        gtk_text_buffer_get_end_iter(buf_recv,&iter);
                                }



                               fseek(recordfile,0,SEEK_CUR);
                              fwrite(resultBuf, strlen(resultBuf),1,recordfile);




                               // recvmark = gtk_text_mark_new(NULL,FALSE);
                               // gtk_text_buffer_add_mark(buf_recv,recvmark,&end);
                              // gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(textView_show),recvmark,1,FALSE,1,1);

                                bzero(chat_msg[i].Name,NAMELEN);
                                bzero(chat_msg[i].msg, 1024);
                        }

                }



           //     g_print("\nreceive: %s", resultBuf);




                //gtk_text_buffer_set_text(buf_recv,tempBuf,-1);
               //sleep(2);
        }
}
/************************************************************************************************/
//选择表情
void cb_image_button_clicked(GtkButton *button, gpointer user_data)
{
            gint offset=0;

        bzero(exp_path,NAMELEN);
        strcpy(exp_path, user_data);
   // gchar *info_ltt3;
  //  gchar * info_ltt2='\0';
  //  gchar temp[100]="#";
        GtkWidget *image;
        GtkTextChildAnchor *anchor;

        buf_send =gtk_text_view_get_buffer(GTK_TEXT_VIEW(textView_send));/*获取文本区*/
	gtk_text_buffer_get_iter_at_offset(buf_send,&start_ltt,offset);


	gtk_text_buffer_get_end_iter(buf_send,&end_ltt);
        gtk_text_buffer_get_text(buf_send,&start_ltt,&end_ltt,FALSE);


        exp_offset = gtk_text_iter_get_offset(&end_ltt);
        g_print("Offset:%d\n",exp_offset);
   // g_print("hello world\n");
	//if(info_ltt3!=NULL)
	//strcat(info_ltt2,info_ltt3);

	image=gtk_image_new_from_file(user_data);

	anchor=gtk_text_buffer_create_child_anchor(buf_send,&end_ltt);

	gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(textView_send),image,anchor);


	gtk_widget_show(image);
	gtk_widget_destroy(expression_window);
	//strcat(temp,user_data);
	//strcat(temp,"#");
	//strcat(info_ltt2,temp);

	//g_print("offset1: %d",offset);

	// offset+=strlen(info_ltt3);
	//g_print("offset2: %d",offset);
	//offset++;
}

/*************************************************************************************************/
/************************************************************************************************/
//聊天表情窗口
void  create_expression_window (GtkButton *button, gpointer user_data)
{
  //GtkWidget *expression_window;
  GdkPixbuf *expression_window_icon_pixbuf;
  GtkWidget *table1;
  GtkWidget *button1;
  GtkWidget *image1;
  GtkWidget *button2;
  GtkWidget *image2;
  GtkWidget *button3;
  GtkWidget *image3;
  GtkWidget *button4;
  GtkWidget *image4;
  GtkWidget *button5;
  GtkWidget *image5;
  GtkWidget *button6;
  GtkWidget *image6;
  GtkWidget *button7;
  GtkWidget *image7;
  GtkWidget *button8;
  GtkWidget *image8;
  GtkWidget *button9;
  GtkWidget *image9;
  GtkWidget *button10;
  GtkWidget *image10;
  GtkWidget *button11;
  GtkWidget *image11;
  GtkWidget *button12;
  GtkWidget *image12;
  GtkWidget *button13;
  GtkWidget *image13;
  GtkWidget *button14;
  GtkWidget *image14;
  GtkWidget *button15;
  GtkWidget *image15;
  GtkWidget *button16;
  GtkWidget *image16;
  GtkWidget *button17;
  GtkWidget *image17;
  GtkWidget *button18;
  GtkWidget *image18;
  GtkWidget *button19;
  GtkWidget *image19;
  GtkWidget *button20;
  GtkWidget *image20;
  GtkWidget *button21;
  GtkWidget *image21;
  GtkWidget *button22;
  GtkWidget *image22;
  GtkWidget *button23;
  GtkWidget *image23;
  GtkWidget *button24;
  GtkWidget *image24;
  GtkWidget *button25;
  GtkWidget *image25;
  GtkWidget *button26;
  GtkWidget *image26;
  GtkWidget *button27;
  GtkWidget *image27;
  GtkWidget *button28;
  GtkWidget *image28;
  GtkWidget *button29;
  GtkWidget *image29;
  GtkWidget *button30;
  GtkWidget *image30;
  GtkWidget *button31;
  GtkWidget *image31;
  GtkWidget *button32;
  GtkWidget *image32;
  GtkWidget *button33;
  GtkWidget *image33;
  GtkWidget *button34;
  GtkWidget *image34;
  GtkWidget *button35;
  GtkWidget *image35;
  GtkWidget *button36;
  GtkWidget *image36;
  GtkWidget *button37;
  GtkWidget *image37;
  GtkWidget *button38;
  GtkWidget *image38;
  GtkWidget *button39;
  GtkWidget *image39;
  GtkWidget *button40;
  GtkWidget *image40;
  GtkWidget *button41;
  GtkWidget *image41;
  GtkWidget *button42;
  GtkWidget *image42;
  GtkWidget *button43;
  GtkWidget *image43;
  GtkWidget *button44;
  GtkWidget *image44;
  GtkWidget *button45;
  GtkWidget *image45;
  GtkWidget *button46;
  GtkWidget *image46;

  expression_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (expression_window), ("expression"));
  expression_window_icon_pixbuf = gdk_pixbuf_new_from_file ("CustomFace/1.gif",NULL);
  if (expression_window_icon_pixbuf)
    {
      gtk_window_set_icon (GTK_WINDOW (expression_window), expression_window_icon_pixbuf);

      gdk_pixbuf_unref (expression_window_icon_pixbuf);
    }

  table1 = gtk_table_new (8,0, TRUE);
  gtk_widget_show (table1);
  gtk_container_add (GTK_CONTAINER (expression_window), table1);

  button1 = gtk_button_new ();
  gtk_widget_show (button1);
  gtk_table_attach (GTK_TABLE (table1), button1, 0, 1, 0, 1,(GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
  image1 = gtk_image_new_from_file("CustomFace/1.gif");
  gtk_widget_show (image1);
  gtk_container_add (GTK_CONTAINER (button1), image1);

  button2 = gtk_button_new ();
  gtk_widget_show (button2);
  gtk_table_attach (GTK_TABLE (table1), button2, 1, 2, 0, 1, (GtkAttachOptions) (GTK_FILL),(GtkAttachOptions) (0), 0, 0);
  image2 = gtk_image_new_from_file("CustomFace/2.gif");
  gtk_widget_show (image2);
  gtk_container_add (GTK_CONTAINER (button2), image2);

  button3 = gtk_button_new ();
  gtk_widget_show (button3);
  gtk_table_attach (GTK_TABLE (table1), button3, 2, 3, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
  image3 = gtk_image_new_from_file("CustomFace/3.gif");
  gtk_widget_show (image3);
  gtk_container_add (GTK_CONTAINER (button3), image3);

  button4 = gtk_button_new ();
  gtk_widget_show (button4);
  gtk_table_attach (GTK_TABLE (table1), button4, 3, 4, 0, 1,  (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
  image4 = gtk_image_new_from_file("CustomFace/4.gif");
  gtk_widget_show (image4);
  gtk_container_add (GTK_CONTAINER (button4), image4);

  button5 = gtk_button_new ();
  gtk_widget_show (button5);
  gtk_table_attach (GTK_TABLE (table1), button5, 4, 5, 0, 1,  (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
  image5 = gtk_image_new_from_file("CustomFace/5.gif");
  gtk_widget_show (image5);
  gtk_container_add (GTK_CONTAINER (button5), image5);

  button6 = gtk_button_new ();
  gtk_widget_show (button6);
  gtk_table_attach (GTK_TABLE (table1), button6, 5, 6, 0, 1,(GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
  image6 = gtk_image_new_from_file("CustomFace/6.gif");
  gtk_widget_show (image6);
  gtk_container_add (GTK_CONTAINER (button6), image6);

  button7 = gtk_button_new ();
  gtk_widget_show (button7);
  gtk_table_attach (GTK_TABLE (table1), button7, 6, 7, 0, 1,(GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
  image7 = gtk_image_new_from_file("CustomFace/7.gif");
  gtk_widget_show (image7);
  gtk_container_add (GTK_CONTAINER (button7), image7);

  button8 = gtk_button_new ();
  gtk_widget_show (button8);
  gtk_table_attach (GTK_TABLE (table1), button8, 7, 8, 0, 1,(GtkAttachOptions) (GTK_FILL),(GtkAttachOptions) (0), 0, 0);
  image8 = gtk_image_new_from_file("CustomFace/8.gif");
  gtk_widget_show (image8);
  gtk_container_add (GTK_CONTAINER (button8), image8);

  button9 = gtk_button_new ();
  gtk_widget_show (button9);
  gtk_table_attach (GTK_TABLE (table1), button9, 8, 9, 0, 1,(GtkAttachOptions) (GTK_FILL),(GtkAttachOptions) (0), 0, 0);
  image9 = gtk_image_new_from_file("CustomFace/9.gif");
  gtk_widget_show (image9);
  gtk_container_add (GTK_CONTAINER (button9), image9);

  button10 = gtk_button_new ();
  gtk_widget_show (button10);
  gtk_table_attach (GTK_TABLE (table1), button10, 9, 10, 0, 1,(GtkAttachOptions) (GTK_FILL),(GtkAttachOptions) (0), 0, 0);
  image10 = gtk_image_new_from_file("CustomFace/10.gif");
  gtk_widget_show (image10);
  gtk_container_add (GTK_CONTAINER (button10), image10);

  button11 = gtk_button_new ();
  gtk_widget_show (button11);
  gtk_table_attach (GTK_TABLE (table1), button11, 10, 11, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
  image11 = gtk_image_new_from_file("CustomFace/11.gif");
  gtk_widget_show (image11);
  gtk_container_add (GTK_CONTAINER (button11), image11);

  button12 = gtk_button_new ();
  gtk_widget_show (button12);
  gtk_table_attach (GTK_TABLE (table1), button12, 0, 1, 1, 2,(GtkAttachOptions) (GTK_FILL),(GtkAttachOptions) (0), 0, 0);
  image12 = gtk_image_new_from_file("CustomFace/12.gif");
  gtk_widget_show (image12);
  gtk_container_add (GTK_CONTAINER (button12), image12);

  button13 = gtk_button_new ();
  gtk_widget_show (button13);
  gtk_table_attach (GTK_TABLE (table1), button13, 1, 2, 1, 2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
  image13 = gtk_image_new_from_file("CustomFace/13.gif");
  gtk_widget_show (image13);
  gtk_container_add (GTK_CONTAINER (button13), image13);

  button14 = gtk_button_new ();
  gtk_widget_show (button14);
  gtk_table_attach (GTK_TABLE (table1), button14, 2, 3, 1, 2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
  image14 = gtk_image_new_from_file("CustomFace/14.gif");
  gtk_widget_show (image14);
  gtk_container_add (GTK_CONTAINER (button14), image14);

  button15 = gtk_button_new ();
  gtk_widget_show (button15);
  gtk_table_attach (GTK_TABLE (table1), button15, 3, 4, 1, 2,(GtkAttachOptions) (GTK_FILL),(GtkAttachOptions) (0), 0, 0);
  image15 = gtk_image_new_from_file("CustomFace/15.gif");
  gtk_widget_show (image15);
  gtk_container_add (GTK_CONTAINER (button15), image15);

  button16 = gtk_button_new ();
  gtk_widget_show (button16);
  gtk_table_attach (GTK_TABLE (table1), button16, 4, 5, 1, 2,(GtkAttachOptions) (GTK_FILL),(GtkAttachOptions) (0), 0, 0);
  image16 = gtk_image_new_from_file("CustomFace/16.gif");
  gtk_widget_show (image16);
  gtk_container_add (GTK_CONTAINER (button16), image16);

  button17 = gtk_button_new ();
  gtk_widget_show (button17);
  gtk_table_attach (GTK_TABLE (table1), button17, 5, 6, 1, 2, (GtkAttachOptions) (GTK_FILL),(GtkAttachOptions) (0), 0, 0);
  image17 = gtk_image_new_from_file("CustomFace/17.gif");
  gtk_widget_show (image17);
  gtk_container_add (GTK_CONTAINER (button17), image17);

  button18 = gtk_button_new ();
  gtk_widget_show (button18);
  gtk_table_attach (GTK_TABLE (table1), button18, 6, 7, 1, 2,(GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
  image18 = gtk_image_new_from_file("CustomFace/18.gif");
  gtk_widget_show (image18);
  gtk_container_add (GTK_CONTAINER (button18), image18);

  button19 = gtk_button_new ();
  gtk_widget_show (button19);
  gtk_table_attach (GTK_TABLE (table1), button19, 7, 8, 1, 2,(GtkAttachOptions) (GTK_FILL),  (GtkAttachOptions) (0), 0, 0);
  image19 = gtk_image_new_from_file("CustomFace/19.gif");
  gtk_widget_show (image19);
  gtk_container_add (GTK_CONTAINER (button19), image19);

  button20 = gtk_button_new ();
  gtk_widget_show (button20);
  gtk_table_attach (GTK_TABLE (table1), button20, 8, 9, 1, 2,  (GtkAttachOptions) (GTK_FILL),(GtkAttachOptions) (0), 0, 0);
  image20 = gtk_image_new_from_file("CustomFace/20.gif");
  gtk_widget_show (image20);
  gtk_container_add (GTK_CONTAINER (button20), image20);

  button21 = gtk_button_new ();
  gtk_widget_show (button21);
  gtk_table_attach (GTK_TABLE (table1), button21, 9, 10, 1, 2,(GtkAttachOptions) (GTK_FILL),(GtkAttachOptions) (0), 0, 0);
  image21 = gtk_image_new_from_file("CustomFace/21.gif");
  gtk_widget_show (image21);
  gtk_container_add (GTK_CONTAINER (button21), image21);

  button22 = gtk_button_new ();
  gtk_widget_show (button22);
  gtk_table_attach (GTK_TABLE (table1), button22, 10, 11, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  image22 = gtk_image_new_from_file("CustomFace/22.gif");
  gtk_widget_show (image22);
  gtk_container_add (GTK_CONTAINER (button22), image22);

  button23 = gtk_button_new ();
  gtk_widget_show (button23);
  gtk_table_attach (GTK_TABLE (table1), button23, 0, 1, 2, 3,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  image23 = gtk_image_new_from_file("CustomFace/23.gif");
  gtk_widget_show (image23);
  gtk_container_add (GTK_CONTAINER (button23), image23);

  button24 = gtk_button_new ();
  gtk_widget_show (button24);
  gtk_table_attach (GTK_TABLE (table1), button24, 1, 2, 2, 3,(GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
  image24 = gtk_image_new_from_file("CustomFace/24.gif");
  gtk_widget_show (image24);
  gtk_container_add (GTK_CONTAINER (button24), image24);

  button25 = gtk_button_new ();
  gtk_widget_show (button25);
  gtk_table_attach (GTK_TABLE (table1), button25, 2, 3, 2, 3, (GtkAttachOptions) (GTK_FILL),(GtkAttachOptions) (0), 0, 0);
  image25 = gtk_image_new_from_file("CustomFace/25.gif");
  gtk_widget_show (image25);
  gtk_container_add (GTK_CONTAINER (button25), image25);

  button26 = gtk_button_new ();
  gtk_widget_show (button26);
  gtk_table_attach (GTK_TABLE (table1), button26, 3, 4, 2, 3, (GtkAttachOptions) (GTK_FILL),(GtkAttachOptions) (0), 0, 0);
  image26 = gtk_image_new_from_file("CustomFace/26.gif");
  gtk_widget_show (image26);
  gtk_container_add (GTK_CONTAINER (button26), image26);

  button27 = gtk_button_new ();
  gtk_widget_show (button27);
  gtk_table_attach (GTK_TABLE (table1), button27, 4, 5, 2, 3, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
  image27 = gtk_image_new_from_file("CustomFace/27.gif");
  gtk_widget_show (image27);
  gtk_container_add (GTK_CONTAINER (button27), image27);

  button28 = gtk_button_new ();
  gtk_widget_show (button28);
  gtk_table_attach (GTK_TABLE (table1), button28, 5, 6, 2, 3, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
  image28 = gtk_image_new_from_file("CustomFace/28.gif");
  gtk_widget_show (image28);
  gtk_container_add (GTK_CONTAINER (button28), image28);

  button29 = gtk_button_new ();
  gtk_widget_show (button29);
  gtk_table_attach (GTK_TABLE (table1), button29, 6, 7, 2, 3, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
  image29 = gtk_image_new_from_file("CustomFace/29.gif");
  gtk_widget_show (image29);
  gtk_container_add (GTK_CONTAINER (button29), image29);

  button30 = gtk_button_new ();
  gtk_widget_show (button30);
  gtk_table_attach (GTK_TABLE (table1), button30, 7, 8, 2, 3, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
  image30 = gtk_image_new_from_file("CustomFace/30.gif");
  gtk_widget_show (image30);
  gtk_container_add (GTK_CONTAINER (button30), image30);

  button31 = gtk_button_new ();
  gtk_widget_show (button31);
  gtk_table_attach (GTK_TABLE (table1), button31, 8, 9, 2, 3, (GtkAttachOptions) (GTK_FILL),(GtkAttachOptions) (0), 0, 0);
  image31 = gtk_image_new_from_file("CustomFace/31.gif");
  gtk_widget_show (image31);
  gtk_container_add (GTK_CONTAINER (button31), image31);

  button32 = gtk_button_new ();
  gtk_widget_show (button32);
  gtk_table_attach (GTK_TABLE (table1), button32, 9, 10, 2, 3, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
  image32 = gtk_image_new_from_file("CustomFace/32.gif");
  gtk_widget_show (image32);
  gtk_container_add (GTK_CONTAINER (button32), image32);

  button33 = gtk_button_new ();
  gtk_widget_show (button33);
  gtk_table_attach (GTK_TABLE (table1), button33, 10, 11, 2, 3, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
  image33 = gtk_image_new_from_file("CustomFace/33.gif");
  gtk_widget_show (image33);
  gtk_container_add (GTK_CONTAINER (button33), image33);

  button34 = gtk_button_new ();
  gtk_widget_show (button34);
  gtk_table_attach (GTK_TABLE (table1), button34, 0, 1, 3, 4, (GtkAttachOptions) (GTK_FILL),(GtkAttachOptions) (0), 0, 0);
  image34 = gtk_image_new_from_file("CustomFace/34.gif");
  gtk_widget_show (image34);
  gtk_container_add (GTK_CONTAINER (button34), image34);

  button35 = gtk_button_new ();
  gtk_widget_show (button35);
  gtk_table_attach (GTK_TABLE (table1), button35, 1, 2, 3, 4,(GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
  image35 = gtk_image_new_from_file("CustomFace/35.gif");
  gtk_widget_show (image35);
  gtk_container_add (GTK_CONTAINER (button35), image35);

  button36 = gtk_button_new ();
  gtk_widget_show (button36);
  gtk_table_attach (GTK_TABLE (table1), button36, 2, 3, 3, 4, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
  image36 = gtk_image_new_from_file("CustomFace/36.gif");
  gtk_widget_show (image36);
  gtk_container_add (GTK_CONTAINER (button36), image36);

  button37 = gtk_button_new ();
  gtk_widget_show (button37);
  gtk_table_attach (GTK_TABLE (table1), button37, 3, 4, 3, 4,(GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
  image37 = gtk_image_new_from_file("CustomFace/37.gif");
  gtk_widget_show (image37);
  gtk_container_add (GTK_CONTAINER (button37), image37);

  button38 = gtk_button_new ();
  gtk_widget_show (button38);
  gtk_table_attach (GTK_TABLE (table1), button38, 4, 5, 3, 4,(GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
  image38 = gtk_image_new_from_file("CustomFace/38.gif");
  gtk_widget_show (image38);
  gtk_container_add (GTK_CONTAINER (button38), image38);

  button39 = gtk_button_new ();
  gtk_widget_show (button39);
  gtk_table_attach (GTK_TABLE (table1), button39, 5, 6, 3, 4,  (GtkAttachOptions) (GTK_FILL),(GtkAttachOptions) (0), 0, 0);
  image39 = gtk_image_new_from_file("CustomFace/39.gif");
  gtk_widget_show (image39);
  gtk_container_add (GTK_CONTAINER (button39), image39);

  button40 = gtk_button_new ();
  gtk_widget_show (button40);
  gtk_table_attach (GTK_TABLE (table1), button40, 6, 7, 3, 4,(GtkAttachOptions) (GTK_FILL),(GtkAttachOptions) (0), 0, 0);
  image40 = gtk_image_new_from_file("CustomFace/40.gif");
  gtk_widget_show (image40);
  gtk_container_add (GTK_CONTAINER (button40), image40);

  button41 = gtk_button_new ();
  gtk_widget_show (button41);
  gtk_table_attach (GTK_TABLE (table1), button41, 7, 8, 3, 4,(GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
  image41 = gtk_image_new_from_file("CustomFace/41.gif");
  gtk_widget_show (image41);
  gtk_container_add (GTK_CONTAINER (button41), image41);

  button42 = gtk_button_new ();
  gtk_widget_show (button42);
  gtk_table_attach (GTK_TABLE (table1), button42, 8, 9, 3, 4,(GtkAttachOptions) (GTK_FILL),(GtkAttachOptions) (0), 0, 0);
  image42 = gtk_image_new_from_file("CustomFace/42.gif");
  gtk_widget_show (image42);
  gtk_container_add (GTK_CONTAINER (button42), image42);

  button43 = gtk_button_new ();
  gtk_widget_show (button43);
  gtk_table_attach (GTK_TABLE (table1), button43, 9, 10, 3, 4,  (GtkAttachOptions) (GTK_FILL),(GtkAttachOptions) (0), 0, 0);
  image43 = gtk_image_new_from_file("CustomFace/43.gif");
  gtk_widget_show (image43);
  gtk_container_add (GTK_CONTAINER (button43), image43);

  button44 = gtk_button_new ();
  gtk_widget_show (button44);
  gtk_table_attach (GTK_TABLE (table1), button44, 10, 11, 3, 4,(GtkAttachOptions) (GTK_FILL),  (GtkAttachOptions) (0), 0, 0);
  image44 = gtk_image_new_from_file("CustomFace/44.gif");
  gtk_widget_show (image44);
  gtk_container_add (GTK_CONTAINER (button44), image44);

  button45 = gtk_button_new ();
  gtk_widget_show (button45);
  gtk_table_attach (GTK_TABLE (table1), button45, 0, 1, 4, 5, (GtkAttachOptions) (GTK_FILL),  (GtkAttachOptions) (0), 0, 0);
  image45 = gtk_image_new_from_file("CustomFace/45.gif");
  gtk_widget_show (image45);
  gtk_container_add (GTK_CONTAINER (button45), image45);

  button46 = gtk_button_new ();
  gtk_widget_show (button46);
  gtk_table_attach (GTK_TABLE (table1), button46, 1, 2, 4, 5,(GtkAttachOptions) (GTK_FILL),(GtkAttachOptions) (0), 0, 0);
  image46 = gtk_image_new_from_file("CustomFace/46.gif");
  gtk_widget_show (image46);
  gtk_container_add (GTK_CONTAINER (button46), image46);

  g_signal_connect (button1, "clicked",  G_CALLBACK (cb_image_button_clicked), "CustomFace/1.gif");
  g_signal_connect (button2, "clicked",G_CALLBACK (cb_image_button_clicked),"CustomFace/2.gif");
  g_signal_connect (button3, "clicked",  G_CALLBACK (cb_image_button_clicked),  "CustomFace/3.gif");
  g_signal_connect (button4, "clicked",G_CALLBACK (cb_image_button_clicked),  "CustomFace/4.gif");
  g_signal_connect (button5, "clicked", G_CALLBACK (cb_image_button_clicked), "CustomFace/5.gif");
  g_signal_connect (button6, "clicked", G_CALLBACK (cb_image_button_clicked), "CustomFace/6.gif");
  g_signal_connect (button7, "clicked", G_CALLBACK (cb_image_button_clicked), "CustomFace/7.gif");
  g_signal_connect (button8, "clicked", G_CALLBACK (cb_image_button_clicked), "CustomFace/8.gif");
  g_signal_connect (button9, "clicked",  G_CALLBACK (cb_image_button_clicked), "CustomFace/9.gif");
  g_signal_connect (button10, "clicked",G_CALLBACK (cb_image_button_clicked),"CustomFace/10.gif");
  g_signal_connect (button11, "clicked",  G_CALLBACK (cb_image_button_clicked), "CustomFace/11.gif");
  g_signal_connect (button12, "clicked",G_CALLBACK (cb_image_button_clicked), "CustomFace/12.gif");
  g_signal_connect (button13, "clicked", G_CALLBACK (cb_image_button_clicked),  "CustomFace/13.gif");
  g_signal_connect (button14, "clicked",G_CALLBACK (cb_image_button_clicked),"CustomFace/14.gif");
  g_signal_connect (button15, "clicked", G_CALLBACK (cb_image_button_clicked),"CustomFace/15.gif");
  g_signal_connect (button16, "clicked",G_CALLBACK (cb_image_button_clicked), "CustomFace/16.gif");
  g_signal_connect (button17, "clicked", G_CALLBACK (cb_image_button_clicked), "CustomFace/17.gif");
  g_signal_connect (button18, "clicked", G_CALLBACK (cb_image_button_clicked), "CustomFace/18.gif");
  g_signal_connect (button19, "clicked", G_CALLBACK (cb_image_button_clicked),  "CustomFace/19.gif");
  g_signal_connect (button20, "clicked", G_CALLBACK (cb_image_button_clicked), "CustomFace/20.gif");
  g_signal_connect (button21, "clicked",G_CALLBACK (cb_image_button_clicked),"CustomFace/21.gif");
  g_signal_connect (button22, "clicked",  G_CALLBACK (cb_image_button_clicked), "CustomFace/22.gif");
  g_signal_connect (button23, "clicked", G_CALLBACK (cb_image_button_clicked), "CustomFace/23.gif");
  g_signal_connect (button24, "clicked",G_CALLBACK (cb_image_button_clicked), "CustomFace/24.gif");
  g_signal_connect (button25, "clicked", G_CALLBACK (cb_image_button_clicked), "CustomFace/25.gif");
  g_signal_connect (button26, "clicked", G_CALLBACK (cb_image_button_clicked),"CustomFace/26.gif");
  g_signal_connect (button27, "clicked",G_CALLBACK (cb_image_button_clicked),"CustomFace/27.gif");
  g_signal_connect (button28, "clicked", G_CALLBACK (cb_image_button_clicked), "CustomFace/28.gif");
  g_signal_connect (button29, "clicked",  G_CALLBACK (cb_image_button_clicked),"CustomFace/29.gif");
  g_signal_connect (button30, "clicked",G_CALLBACK (cb_image_button_clicked),"CustomFace/30.gif");
  g_signal_connect (button31, "clicked",G_CALLBACK (cb_image_button_clicked), "CustomFace/31.gif");
  g_signal_connect (button32, "clicked", G_CALLBACK (cb_image_button_clicked),  "CustomFace/32.gif");
  g_signal_connect (button33, "clicked",G_CALLBACK (cb_image_button_clicked),"CustomFace/33.gif");
  g_signal_connect (button34, "clicked", G_CALLBACK (cb_image_button_clicked), "CustomFace/34.gif");
  g_signal_connect (button35, "clicked", G_CALLBACK (cb_image_button_clicked), "CustomFace/35.gif");
  g_signal_connect (button36, "clicked", G_CALLBACK (cb_image_button_clicked),"CustomFace/36.gif");
  g_signal_connect (button37, "clicked",G_CALLBACK (cb_image_button_clicked),"CustomFace/37.gif");
  g_signal_connect (button38, "clicked",  G_CALLBACK (cb_image_button_clicked),"CustomFace/38.gif");
  g_signal_connect (button39, "clicked", G_CALLBACK (cb_image_button_clicked), "CustomFace/39.gif");
  g_signal_connect (button40, "clicked",G_CALLBACK (cb_image_button_clicked),"CustomFace/40.gif");
  g_signal_connect (button41, "clicked",G_CALLBACK (cb_image_button_clicked),"CustomFace/41.gif");
  g_signal_connect (button42, "clicked",  G_CALLBACK (cb_image_button_clicked), "CustomFace/43.gif");
  g_signal_connect (button44, "clicked", G_CALLBACK (cb_image_button_clicked),  "CustomFace/44.gif");
  g_signal_connect (button45, "clicked", G_CALLBACK (cb_image_button_clicked), "CustomFace/45.gif");
  g_signal_connect (button46, "clicked", G_CALLBACK (cb_image_button_clicked), "CustomFace/46.gif");

  gtk_widget_show_all(expression_window);
}
void  on_bt_infook_clicked (GtkButton *button, gpointer user_data)
{
    gtk_widget_destroy(infowindow);
}
void  show_pesornal_info (GtkButton *button, clientRequest *user_data)
{
    clientRequest personalinfo = *user_data;

    GtkBuilder *mybuilder;

    GtkWidget *entry1;
    GtkWidget *entry2;
    GtkWidget *entry3;
    GtkWidget *entry4;
    GtkWidget *entry5;
    GtkWidget *entry6;
    GtkWidget *entry7;
    GtkWidget *entry8;
    GtkWidget *image1;
    GtkWidget *bt_infook;
    char myage[5];
    char name[10];
    char imagepath[30];



    sprintf(imagepath,"./NormalFace/%d.bmp",personalinfo.profilepic);

    sprintf(myage,"%d",personalinfo.age);
    //sprintf(name,"%s 的个人信息",personalinfo.senderName);
    mybuilder = gtk_builder_new();
	gtk_builder_add_from_file(mybuilder,"personalinfo.glade",NULL);

    infowindow = GTK_WIDGET(gtk_builder_get_object(mybuilder,"infowindow"));
    entry1 = GTK_WIDGET(gtk_builder_get_object(mybuilder,"entry1"));
    entry2= GTK_WIDGET(gtk_builder_get_object(mybuilder,"entry2"));
    entry3 = GTK_WIDGET(gtk_builder_get_object(mybuilder,"entry3"));
    entry4 = GTK_WIDGET(gtk_builder_get_object(mybuilder,"entry4"));
    entry5 = GTK_WIDGET(gtk_builder_get_object(mybuilder,"entry5"));
    entry6 = GTK_WIDGET(gtk_builder_get_object(mybuilder,"entry6"));
    entry7 = GTK_WIDGET(gtk_builder_get_object(mybuilder,"entry7"));
    entry8 = GTK_WIDGET(gtk_builder_get_object(mybuilder,"entry8"));
    image1 = GTK_WIDGET(gtk_builder_get_object(mybuilder,"image1"));
    bt_infook = GTK_WIDGET(gtk_builder_get_object(mybuilder,"bt_infook"));

    gtk_window_set_title (GTK_WINDOW (infowindow), "个人信息");
    gtk_entry_set_text (GTK_ENTRY(entry1),personalinfo.nickName);
    gtk_entry_set_text (GTK_ENTRY(entry2),personalinfo.senderName);
    gtk_entry_set_text (GTK_ENTRY(entry3),personalinfo.sourceIP);
    gtk_entry_set_text (GTK_ENTRY(entry4),myage);
    gtk_entry_set_text (GTK_ENTRY(entry5),personalinfo.gender);
    gtk_entry_set_text (GTK_ENTRY(entry6),personalinfo.branch);
    g_print("%s : %s \n",personalinfo.senderName,personalinfo.branch);
    gtk_entry_set_text (GTK_ENTRY(entry7),personalinfo.telephone);
    gtk_entry_set_text (GTK_ENTRY(entry8),personalinfo.birthdate);
    gtk_image_set_from_file(GTK_IMAGE(image1),imagepath);

    bzero(myage,sizeof(myage ));
    bzero(name,sizeof(name));
    bzero(imagepath,sizeof(imagepath));




    g_signal_connect(G_OBJECT(bt_infook),"clicked",G_CALLBACK(on_bt_infook_clicked),NULL);
    gtk_builder_connect_signals(mybuilder,NULL);
	g_object_unref(G_OBJECT(mybuilder));

    gtk_widget_show(infowindow);
    gtk_main();


}
/*
void *send_file( void *arg)
{
    gtk_widget_destroy(GTK_WIDGET(filew));
    gchar sendfilemsg[100];
    int sendfilefd;
    struct sockaddr_in sendfile_addr;
    sendfilefd = socket(AF_INET, SOCK_DGRAM, 0);
    bzero(&sendfile_addr, sizeof(sendfile_addr));
 //   setsockopt(sendSockfd,SOL_SOCKET,SO_BROADCAST,&sendSockfd,sizeof(sendSockfd));
    sendfile_addr.sin_family = AF_INET;
    sendfile_addr.sin_addr.s_addr = inet_addr(SERVERIP);
    sendfile_addr.sin_port = htons(9741);


                sendfilemsg[0] = '6';
                strcat(sendfilemsg,"~");                                                                                                                                //组包
                strcat(sendfilemsg,myinformation.senderName);
                strcat(sendfilemsg,"~");
                strcat(sendfilemsg,clientinfo.senderName);
                strcat(sendfilemsg,"~");
                //strcat(message,Register_PasswdEntry_char);
                strcat(sendfilemsg,"~");
                strcat(sendfilemsg,myinformation.sourceIP);
                strcat(sendfilemsg,"~");

                strcat(sendfilemsg,clientinfo.sourceIP);

                strcat(sendfilemsg,"~");
                //nickname
                strcat(sendfilemsg,"~");
                //state
                strcat(sendfilemsg,"~");
                //strcat(message,Register_GenderEntry_char);
                strcat(sendfilemsg,"~");
                //strcat(message,Register_AgeEntry_char);
                strcat(sendfilemsg,"~");
                //strcat(message,Register_DepartEntry_char);
                strcat(sendfilemsg,"~");
                //tel
                strcat(sendfilemsg,"~");
                //birth
                strcat(sendfilemsg,"~");
                //profilepic
                strcat(sendfilemsg,"~");
                //msg
              //  strcat(sendmessage,S_text);
                strcat(sendfilemsg,"~");



    sendto(sendfilefd, sendfilemsg, strlen(sendfilemsg)+1,0, (struct sockaddr *)&sendfile_addr, sizeof(sendfile_addr));
    g_print ("message :%s \n",sendfilemsg);
    sleep(2);
    gtk_text_buffer_set_text(buf_send,"",-1);
    close(sendfilefd);
    printf("./LPESupport %s %s %s",fileoptype,filepath,senderip);
    execl("./LPFSupport","./LPFSupport",fileoptype,filepath,senderip,(char * )0) ;
    return ((char *)0);

}
*/


void  file_ok_select (GtkWidget *w,GtkFileSelection *fs)
{
    pid_t pid;
     g_print ("%s\n", gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)));

    // pthread_t sendfile;
     filepath = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs));
   //  senderip =
     g_print("%s\n",filepath);
     senderip = clientinfo.sourceIP;
     fileoptype = "s";
  //  pthread_create(&sendfile,NULL,send_file,NULL);
    pid = fork();
    switch(pid)
    {
        case -1:
        perror("fork failed");
        exit(1);
        case 0:
        gtk_widget_destroy(GTK_WIDGET(filew));
    gchar sendfilemsg[100];
    bzero(sendfilemsg,sizeof(sendfilemsg));
    int sendfilefd;
    struct sockaddr_in sendfile_addr;
    sendfilefd = socket(AF_INET, SOCK_DGRAM, 0);
    bzero(&sendfile_addr, sizeof(sendfile_addr));
 //   setsockopt(sendSockfd,SOL_SOCKET,SO_BROADCAST,&sendSockfd,sizeof(sendSockfd));
    sendfile_addr.sin_family = AF_INET;
    sendfile_addr.sin_addr.s_addr = inet_addr(SERVERIP);
    sendfile_addr.sin_port = htons(9741);

                sendfilemsg[0] = '6';
                strcat(sendfilemsg,"~");                                                                                                                                //组包
                strcat(sendfilemsg,myinformation.senderName);
                strcat(sendfilemsg,"~");
                strcat(sendfilemsg,clientinfo.senderName);
                strcat(sendfilemsg,"~");
                //strcat(message,Register_PasswdEntry_char);
                strcat(sendfilemsg,"~");
                strcat(sendfilemsg,myinformation.sourceIP);
                strcat(sendfilemsg,"~");

                strcat(sendfilemsg,clientinfo.sourceIP);

                strcat(sendfilemsg,"~");
                //nickname
                strcat(sendfilemsg,"~");
                //state
                strcat(sendfilemsg,"~");
                //strcat(message,Register_GenderEntry_char);
                strcat(sendfilemsg,"~");
                //strcat(message,Register_AgeEntry_char);
                strcat(sendfilemsg,"~");
                //strcat(message,Register_DepartEntry_char);
                strcat(sendfilemsg,"~");
                //tel
                strcat(sendfilemsg,"~");
                //birth
                strcat(sendfilemsg,"~");
                //profilepic
                strcat(sendfilemsg,"~");
                //msg
              //  strcat(sendmessage,S_text);
                strcat(sendfilemsg,"~");



        sendto(sendfilefd, sendfilemsg, strlen(sendfilemsg)+1,0, (struct sockaddr *)&sendfile_addr, sizeof(sendfile_addr));
        g_print ("message :%s \n",sendfilemsg);
        sleep(2);
        gtk_text_buffer_set_text(buf_send,"",-1);
        close(sendfilefd);
        printf("./LPESupport %s %s %s",fileoptype,filepath,senderip);
        execl("./LPFSupport","./LPFSupport",fileoptype,filepath,senderip,(char * )0);
        break;
        default :
        break;

    }

}

void  on_sendfile_button_clicked (GtkButton *button, clientRequest *user_data)
{

    //tk_init (&argc, &argv);
    /* 创建一个新的文件选择构件 */
    filew = gtk_file_selection_new ("File selection");
    g_signal_connect (G_OBJECT (filew), "destroy",G_CALLBACK (gtk_main_quit), NULL);
    /* 为ok_button按钮设置回调函数，连接到file_ok_sel function函数 */
    g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (filew)->ok_button),"clicked",G_CALLBACK (file_ok_select), filew);
    /* 为cancel_button设置回调函数，销毁构件 */
    g_signal_connect_swapped (G_OBJECT (GTK_FILE_SELECTION (filew)->cancel_button),"clicked",G_CALLBACK (gtk_widget_destroy), filew);
    /* 设置文件名，比如这个一个文件保存对话框，我们给了一个缺省文件名*/
    gtk_file_selection_set_filename (GTK_FILE_SELECTION(filew),"penguin.png");
    gtk_widget_show (filew);
    gtk_main ();

}

/***********************************************************************************************/
void show_conversation_window(GtkButton *button, clientRequest * user_data)
{
    clientRequest tempclient = * user_data;
    clientinfo = * user_data;
        //把闪动的头像恢复正常
    int m,n;
    for(m=0;m<user_num;m++)
    {

        if(strcmp(user_window[m].Name,tempclient.senderName)  == 0)
        {
            n = m;
            break;
        }

    }
    printf("%s 你的头像在闪吗？ \n  %s你的窗口被打开了 \n",user_window[n].Name,tempclient.senderName);
    printf(" flag = %d",user_window[n].flag);
    printf("n= %d m=%d \n",n,m);
    if(user_window[n].flag ==1 )
    {
        g_print("%s 你别闪了",user_window[n].Name);
        g_print("flag: %d",user_window[n].flag);
        pthread_cancel(drawimage_t);
        int j,temp;
        for(j=0;j<user_num;j++)
        {
            if(strcmp(clientinfo.senderName,userinfo[j].senderName) ==0)
            {
                temp = j;
                break;
            }

        }
        gtk_widget_show(image1[temp]);
    }

    user_window[n].flag =1;



   // g_print("user_name :%s \n",tempclient.senderName);
   // g_print("user_age :%d \n",tempclient.age);
    pthread_t recv_thread;
  //  pthread_t pth_record;

  //  gtk_init(&argc,&argv);
	builder = gtk_builder_new();
	gtk_builder_add_from_file(builder,"ptp.glade",NULL);
    GtkWidget *Btn_rec;
    GtkWidget * vbox4;
    GtkWidget * vbox5;
    GtkWidget *frame1;
    GtkWidget *label1;
    GtkWidget *frame2;
    GtkWidget *label2;
    GtkWidget *btn_face;
    GtkWidget *btn_myimage;
    GtkWidget *btn_sendimage;
    GtkWidget *myimage;
    GtkWidget *sendimage;
    GtkWidget *sendfile;
    GtkWidget *scrolledwindow1;
    gchar myimagepath[30];
    gchar sendimagepath[30];

    bzero(myimagepath,sizeof(myimagepath));
    bzero(sendimagepath,sizeof(sendimagepath));
    gchar windowtitle[30]={0};


	window = GTK_WIDGET(gtk_builder_get_object(builder,"window1"));
    btnsend = GTK_WIDGET(gtk_builder_get_object(builder,"BTN_send"));
    btn_face = GTK_WIDGET(gtk_builder_get_object(builder,"btn_face"));
    textView_show = GTK_WIDGET(gtk_builder_get_object(builder,"TEXT_show"));
    textView_send = GTK_WIDGET(gtk_builder_get_object(builder,"TEXT_send"));
    Btn_rec = GTK_WIDGET(gtk_builder_get_object(builder,"Btn_recording"));
    vbox4 = GTK_WIDGET(gtk_builder_get_object(builder,"vbox4"));
    vbox5 = GTK_WIDGET(gtk_builder_get_object(builder,"vbox5"));
    btn_myimage = GTK_WIDGET(gtk_builder_get_object(builder,"btn_myimage"));
    btn_sendimage = GTK_WIDGET(gtk_builder_get_object(builder,"btn_sendimage"));
    sendfile = GTK_WIDGET(gtk_builder_get_object(builder,"sendfile_button"));
    scrolledwindow1 = GTK_WIDGET(gtk_builder_get_object(builder,"scrolledwindow1"));
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow1),GTK_POLICY_AUTOMATIC,GTK_POLICY_ALWAYS);
    sprintf(windowtitle,"与 %s 聊天中",tempclient.senderName);
    gtk_window_set_title (GTK_WINDOW (window), windowtitle);

    sprintf(myimagepath,"./BigFace/%d.bmp",myinformation.profilepic);
     myimage = gtk_image_new_from_file(myimagepath);
    gtk_widget_show (myimage);
    gtk_container_add (GTK_CONTAINER (btn_myimage), myimage);

    sprintf(sendimagepath,"./BigFace/%d.bmp",tempclient.profilepic);
    sendimage = gtk_image_new_from_file(sendimagepath);
    gtk_widget_show (sendimage);
    gtk_container_add (GTK_CONTAINER (btn_sendimage), sendimage);

    frame1 = gtk_frame_new("IP");
    label1 = gtk_label_new(tempclient.sourceIP);
    gtk_container_add(GTK_CONTAINER(frame1),label1);
   gtk_box_pack_start(GTK_BOX(vbox4),frame1,FALSE,FALSE,0);
 //   gtk_container_add(GTK_CONTAINER(window),vbox4);
    frame2 = gtk_frame_new("IP");
    label2 = gtk_label_new(myinformation.sourceIP);
    gtk_container_add(GTK_CONTAINER(frame2),label2);
   gtk_box_pack_start(GTK_BOX(vbox5),frame2,FALSE,FALSE,0);

    recordfile = fopen("./record.txt", "a+");
    if(recordfile == NULL)
        exit(0);

    g_signal_connect(G_OBJECT(btnsend),"clicked",G_CALLBACK(on_BTN_send_clicked),&tempclient);
    g_signal_connect(G_OBJECT(window),"delete_event",G_CALLBACK(close_window),NULL);
    g_signal_connect(G_OBJECT(Btn_rec),"clicked",G_CALLBACK(show_recording_window),NULL);
    g_signal_connect(G_OBJECT(btn_face),"clicked",G_CALLBACK(create_expression_window),NULL);
    g_signal_connect(G_OBJECT(btn_myimage),"clicked",G_CALLBACK(show_pesornal_info),&myinformation);
     g_signal_connect(G_OBJECT(btn_sendimage),"clicked",G_CALLBACK(show_pesornal_info),&tempclient);
    g_signal_connect(G_OBJECT(sendfile),"clicked",G_CALLBACK(on_sendfile_button_clicked),NULL);

	gtk_builder_connect_signals(builder,NULL);
	g_object_unref(G_OBJECT(builder));
 // pthread_create(&pth_record, NULL, chart_record, NULL);
	pthread_create(&recv_thread, NULL, recv_func, NULL);

    gtk_widget_show_all (window);
    gtk_main();
}


/************************************************************************************************************/
//群会话

//void * bulktalking_pthread(void * arg)
//

//}
typedef struct GroupComm
{
    char targetName[NAMELEN];
    char destIP[16];
    unsigned short ifFucked;
}groupComm;

int sin_len;
int socket_fd;
struct sockaddr_in add_from;

int GroupMemberCount = 0;
//int user_num = MAXMEMBER;///给出目前的总用户数，可以由风神给出~
//static struct ClientRequest userinfo[MAXMEMBER];
static struct GroupComm groupmember[MAXMEMBER];
//clientRequest* myself;

char buffer[MSGLEN] = {0};



int getPeer(clientRequest *myself
            , clientRequest *allCollegues
            , groupComm *groupmember)
{
    char* mybranch;
    mybranch = (char*)malloc(sizeof(char)*50);
    bzero(mybranch, 50);

    strcpy(mybranch, myself->branch);
    printf("I am in %s.\n", mybranch);

    int CollegueCount = 0;

    while(CollegueCount < user_num)
    {
        printf("%s\n", groupmember[CollegueCount].destIP);

        if(!strcmp(mybranch, allCollegues[CollegueCount].branch))
        {
            strcpy(groupmember[GroupMemberCount].targetName
                , allCollegues[CollegueCount].senderName);
            strcpy(groupmember[GroupMemberCount].destIP
                , allCollegues[CollegueCount].sourceIP);
            groupmember[GroupMemberCount].ifFucked = allCollegues[CollegueCount].profilepic;
            printf("群里有我：%s",groupmember[GroupMemberCount].targetName);
            printf("我的IP： %s",groupmember[GroupMemberCount].destIP);
            //groupmember[GroupMemberCount].ifFucked = 0;
            GroupMemberCount++;
        }
        CollegueCount++;
    }
    return 0;
}
int sendtoPeer(char* buffer)
{
        int ret;
       // groupComm mygroupmember = *groupmember;
        struct sockaddr_in add;
		socket_fd = socket(AF_INET,SOCK_DGRAM,0);
		printf("发送消息了！\n");
		if(socket_fd == -1)
		{
				perror("socket");
				exit(1);
		}
		//printf("groupmember[3] :%s\n",groupmember[3].targetName);

		add.sin_family = AF_INET;
		add.sin_port = htons(PORT);
		int i;
		for(i = 0;i< GroupMemberCount;i++)
		{
		    printf("groupmember[%d].destIP = %s \n",i,groupmember[i].destIP);
		    printf("groupmember[%d].name = %s \n",i,groupmember[i].targetName);
		    add.sin_addr.s_addr =inet_addr(groupmember[i].destIP);
		    ret = sendto(socket_fd
                   , buffer
                   , strlen(buffer)+1
                   , 0
                   , (struct sockaddr*)&add
                   , sizeof(add));
            if(ret == -1)
            {
                perror("sendto.sha");
                exit(1);
            }
		}
		close(socket_fd);
        return 0;
}


void on_gpsendbtn_clicked(GtkObject *object,gpointer user_data)
{
    gchar gpmessage[1024];

    GtkTextIter start,end;           /*定义迭代器起点终点*/
    gchar * GP_text;

    buf_gpsend = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textView_gpsend));     /*获取文本区*/
    gtk_text_buffer_get_start_iter(buf_gpsend,&start);                                          /*得到当前文本区域的起始位置*/
    gtk_text_buffer_get_end_iter(buf_gpsend,&end);                                              /*得到当前文本区域的结束位置*/
    GP_text = gtk_text_buffer_get_text(buf_gpsend,&start,&end,TRUE);         /*返回start end之间的所有文本，最后一个参数是TRUE的话那么可见的文本都将被返回*/

    bzero(gpmessage,sizeof(gpmessage));
                gpmessage[0] = '7';
                strcat(gpmessage,"~");                                                                                                                                //组包
                strcat(gpmessage,myinformation.senderName);
                strcat(gpmessage,"~");
                //strcat(gpmessage,usermsg.senderName);
                strcat(gpmessage,"~");
                //strcat(message,Register_PasswdEntry_char);
                strcat(gpmessage,"~");
                //sourceIP
                strcat(gpmessage,myinformation.sourceIP);
                strcat(gpmessage,"~");

                //strcat(gpmessage,usermsg.sourceIP);

                strcat(gpmessage,"~");
                //nickname
                strcat(gpmessage,"~");
                //state
                strcat(gpmessage,"~");
                //strcat(message,Register_GenderEntry_char);
                strcat(gpmessage,"~");
                //strcat(message,Register_AgeEntry_char);
                strcat(gpmessage,"~");
                //strcat(message,Register_DepartEntry_char);
                strcat(gpmessage,myinformation.branch);
                strcat(gpmessage,"~");
                //tel
                strcat(gpmessage,"~");
                //birth
                strcat(gpmessage,"~");
                //profilepic
                strcat(gpmessage,"~");
                //msg
                strcat(gpmessage,GP_text);
                strcat(gpmessage,"~");
                printf("我发的群消息: %s",gpmessage);
                printf("dasdsad 群里有我：%s \n",groupmember[2].targetName);

                sendtoPeer(gpmessage);
                gtk_text_buffer_set_text(buf_gpsend,"",-1);

                close(socket_fd);



}


void * rev_groupmsg_pthread(void * arg)
{

        char resultBuf[1500] = {0};
        char time_msg[50];
        time_t now;
        struct tm * ptr;
        GtkTextIter iter;

        while(1)
        {
                int i ;
                for(i = 0; i < 10; i++)
                {
                        if(strcmp(gpchat_msg[i].branch, myinformation.branch)==0)
                        {
                            printf("i = %d \n",i);
                                //GtkTextMark * recvmark;
                                //GtkTextIter end;
                                time(&now);
                                ptr = localtime(&now);
                                strftime(time_msg,sizeof(time_msg),"%T", ptr);
                                sprintf(resultBuf,"%s     %s\n%s\n\n",gpchat_msg[i].Name,time_msg, gpchat_msg[i].msg);
                                fseek(recordfile,0,SEEK_CUR);
                                fwrite(resultBuf, strlen(resultBuf),1,recordfile);//(recordfile,resultBuf,strlen(resultBuf)+1);//写入聊天记录文件

                                buf_gprecv = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textView_gpshow));
                                gtk_text_buffer_get_iter_at_offset(buf_gprecv, &iter, -1);
                                //gtk_text_buffer_get_end_iter(buf_recv,&end);
                                gtk_text_buffer_insert_with_tags_by_name (buf_gprecv, &iter, resultBuf, -1, NULL,NULL, NULL);
                               // recvmark = gtk_text_mark_new(NULL,FALSE);
                               // gtk_text_buffer_add_mark(buf_recv,recvmark,&end);
                              // gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(textView_gpshow),recvmark,1,FALSE,1,1);

                                bzero(gpchat_msg[i].Name,NAMELEN);
                                bzero(gpchat_msg[i].msg, 1024);
                                bzero(gpchat_msg[i].branch, 30);
                                bzero(resultBuf,sizeof(resultBuf));
                        }
                }

            }

}
void on_MygroupBtn_clicked(GtkObject *object,gpointer user_data)
{
    printf("test1 \n");
    GtkWidget *GroupWindow;
    //GtkWidget *gpbtnsend;
    GtkWidget *gpsendbtn;
    GtkWidget *gpbtn_face;

    GtkWidget *gpsendfile;
    GtkWidget *gprecord;
    GtkWidget *scrolledwindow3;
    GtkWidget *fixed1;
    GtkWidget *button[100];
    GtkWidget *image[100];
    GtkWidget *label[100];
    gchar imagepath[30];
    pthread_t bulktalking_pthread_t;

  //  GtkWidget *gpwindowtitle;

   // pthread_t recv_thread;

	Group_builder = gtk_builder_new();
	gtk_builder_add_from_file(Group_builder,"Group.glade",NULL);

    gchar gpwindowtitle[30]={0};
    //recordfile = fopen("./record.txt",O_CREAT|O_RDWR|O_APPEND,0777);
   // recordfile = fopen("./record.txt", "a+");
    //if(recordfile == NULL) exit(0);


	GroupWindow = GTK_WIDGET(gtk_builder_get_object(Group_builder,"GroupWindow"));
    gpsendbtn = GTK_WIDGET(gtk_builder_get_object(Group_builder,"gpsendbtn"));
    gpbtn_face = GTK_WIDGET(gtk_builder_get_object(Group_builder,"gpbtn_face"));
    textView_gpshow = GTK_WIDGET(gtk_builder_get_object(Group_builder,"textView_gpshow"));
    textView_gpsend = GTK_WIDGET(gtk_builder_get_object(Group_builder,"textView_gpsend"));
    gpsendfile = GTK_WIDGET(gtk_builder_get_object(Group_builder,"gpsendfile"));
    gprecord = GTK_WIDGET(gtk_builder_get_object(Group_builder,"gprecord"));
    scrolledwindow3 =GTK_WIDGET(gtk_builder_get_object(Group_builder,"scrolledwindow3"));

    fixed1 = gtk_fixed_new();
    gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolledwindow3), fixed1);


    sprintf(gpwindowtitle,"%s 群会话",myinformation.branch);
    gtk_window_set_title (GTK_WINDOW (GroupWindow), gpwindowtitle);
/********************************************************************************************************/


///@mage: 请你给出存储目前用户的个人信息的数组元素
    //其的类型是clientRequest* 名字叫做myself.
    //设所有用户信息结构题数组里userinfo[59]是目前用户的个人信息
    //则，可以设置clientRequest* myself = (userinfo + 59);
    printf("test2 \n");
    getPeer(&myinformation, userinfo, groupmember);
//    char fanhuilaideIP[16];

    int temp = GroupMemberCount;//保存和自己一个群组的人数
      printf("test3 \n");
    int i;
    for(i = 0;i<temp; i++)
    {
      ImageNo[i] = i;
      button[i] = gtk_button_new();
      gtk_fixed_put(GTK_FIXED(fixed1),button[i],20,(10+80*i));
      gtk_widget_set_size_request(button[i], 60, 60);

      sprintf(imagepath,"./LittleFace/%d.bmp",groupmember[i].ifFucked);
      image[i] = gtk_image_new_from_file(imagepath);
      gtk_container_add (GTK_CONTAINER (button[i]), image[i]);
      //g_signal_connect(G_OBJECT(button[i]),"clicked",G_CALLBACK(on_selectimage_button_clicked),&ImageNo[i]);
      label[i] = gtk_label_new(groupmember[i].targetName);
      gtk_fixed_put(GTK_FIXED(fixed1), label[i], 80, (30+80*i));
      gtk_widget_set_size_request(label[i], 100, 40);

    }


    pthread_create(&bulktalking_pthread_t,NULL,rev_groupmsg_pthread,NULL);
      printf("test4 \n");

  //  sin_len = sizeof(struct sockaddr_in);
  //  int flag = 0;

   /* sendtoPeer(buffer);

    if(fork()==0)
        while(1)
        {
            recvfrom(socket_fd, buffer, sizeof(buffer), 0,(struct sockaddr*)&add_from, &sin_len);
            strcpy(fanhuilaideIP, inet_ntoa(add_from.sin_addr));

            while(temp >= 0 && flag != 1)
            {
                if(fanhuilaideIP == groupmember[temp].destIP)
                {
                    flag =1;
                }
            }
            ///@mabee: 此时，flag==1表示你应当把buffer显示到对话框里
            sleep(1);
        }
*/
/*********************************************************************************************************/


  //  g_signal_connect(G_OBJECT(gpsendbtn),"clicked",G_CALLBACK(on_GPBTN_send_clicked),NULL);
  //  g_signal_connect(G_OBJECT(GroupWindow),"delete_event",G_CALLBACK(close_GroupWindow),NULL);
    g_signal_connect(G_OBJECT(gprecord),"clicked",G_CALLBACK(show_recording_window),NULL);
    g_signal_connect(G_OBJECT(gpbtn_face),"clicked",G_CALLBACK(create_expression_window),NULL);
    g_signal_connect(G_OBJECT(gpsendbtn),"clicked",G_CALLBACK(on_gpsendbtn_clicked),NULL);


    g_signal_connect(G_OBJECT(gpsendfile),"clicked",G_CALLBACK(on_sendfile_button_clicked),NULL);
	gtk_builder_connect_signals(Group_builder,NULL);
	g_object_unref(G_OBJECT(Group_builder));
 // pthread_create(&pth_record, NULL, chart_record, NULL);
//	pthread_create(&recv_thread, NULL, recv_func, NULL);

    gtk_widget_show_all(GroupWindow);
    //gtk_main();
    //return 0;
}




#endif
